package com.hmall.common.config;

import com.hmall.common.interceptor.LoginInterceptor;
import org.checkerframework.checker.units.qual.C;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ConditionalOnClass(DispatcherServlet.class)
// SpringMvc的核心Servlet作为该配置类加载的前提条件，这样就可以避免hm-common启动报错（hm-common没有引用SpringMvc）
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor());
    }
}
